Running an analysis

The solver module is used to interact with OpenSees.

The most convenient approach is using a child of the Analysis class from those already defined in the solver module for the specific analysis that is needed. This will run the analysis and store the requested results of each analysis step.

Alternatively, a generic Analysis object can be defined (from the parent class), and its generic methods for model definition can be used together with OpenSees commands issued directly in the analysis script. If such an analysis is repeated a lot, a new Analysis child class can be defined in the solver module.

Analysis examples

First, we need to define a model.

[1]:
# This cell defines the model from notebook 2_Define_a_Model
import numpy as np
from osmg import model
import osmg.defaults as defaults
from osmg.gen.section_gen import SectionGenerator
from osmg.ops.section import ElasticSection
from osmg.gen.component_gen import BeamColumnGenerator
from osmg.ops.element import ElasticBeamColumn
from osmg.gen.zerolength_gen import gravity_shear_tab
from osmg.load_case import LoadCase
from osmg.preprocessing.self_weight_mass import self_weight
from osmg.preprocessing.self_weight_mass import self_mass
from osmg.preprocessing.tributary_area_analysis import PolygonLoad
from osmg.graphics.preprocessing_3d import show
mdl = model.Model('example_model')
for i in range(3):
    mdl.add_level(i, 144.00*(i))
defaults.load_default_steel(mdl)
defaults.load_default_fix_release(mdl)
defaults.load_util_rigid_elastic(mdl)
steel_phys_mat = mdl.physical_materials.retrieve_by_attr('name', 'default steel')
secg = SectionGenerator(mdl)
secg.load_aisc_from_database(
    'W',
    ["W24X94"],
    'default steel',
    'default steel',
    ElasticSection)
mdl.levels.set_active([1, 2])
p1 = np.array((0.00, 0.00))
p2 = np.array((360., 0.00))
p3 = np.array((360., 360.))
p4 = np.array((0.00, 360.00))
mcg = BeamColumnGenerator(mdl)
sec = mdl.elastic_sections.retrieve_by_attr('name', 'W24X94')
for pt in [p1, p2, p3, p4]:
    mcg.add_pz_active(
        pt[0], pt[1],
        sec,
        steel_phys_mat,
        0.00,
        24.00,
        24.00,
        0.00,
        0.02)
    mcg.add_vertical_active(
        x_coord=pt[0], y_coord=pt[1],
        offset_i=np.zeros(3), offset_j=np.zeros(3),
        transf_type='Corotational',
        n_sub=1,
        section=sec,
        element_type=ElasticBeamColumn,
        placement='centroid',
        angle=0.00)
snap_i_list = ['centroid', 'middle_front', 'centroid', 'middle_back']
snap_j_list = ['centroid', 'middle_back', 'centroid', 'middle_front']
for i, pair in enumerate([(p1, p2), (p2, p3), (p3, p4), (p4, p1)]):
    mcg.add_horizontal_active(
        xi_coord=pair[0][0],
        yi_coord=pair[0][1],
        xj_coord=pair[1][0],
        yj_coord=pair[1][1],
        offset_i=np.zeros(3),
        offset_j=np.zeros(3),
        snap_i=snap_i_list[i],
        snap_j=snap_j_list[i],
        transf_type='Linear',
        n_sub=4,
        section=sec,
        element_type=ElasticBeamColumn,
        placement='top_center',
        angle=0.00,
        method='generate_hinged_component_assembly',
        additional_args={
            'zerolength_gen_i': gravity_shear_tab,
            'zerolength_gen_args_i': {
                'consider_composite': True,
                'section': sec,
                'physical_material': steel_phys_mat,
                'distance': 10.00,
                'n_sub': 2
            },
            'zerolength_gen_j': gravity_shear_tab,
            'zerolength_gen_args_j': {
                'consider_composite': True,
                'section': sec,
                'physical_material': steel_phys_mat,
                'distance': 10.00,
                'n_sub': 2
            }
        }
    )
for node in mdl.levels[0].nodes.values():
    node.restraint = [True]*6
testcase = LoadCase('test', mdl)
self_weight(mdl, testcase)
self_mass(mdl, testcase)
testcase.rigid_diaphragms([1, 2])
# for key in [1, 2]:
#     testcase.tributary_area_analysis[key].polygon_loads.append(
#         PolygonLoad('dead', 5.00, None, None, False))
#     testcase.tributary_area_analysis[key].polygon_loads.append(
#         PolygonLoad('live', 1.00, None, None, True))
#     testcase.tributary_area_analysis[key].run()
[2]:
show(mdl, testcase, extrude=True)

Static Analysis

[3]:
from osmg import solver
[4]:
# instantiate analysis object
static_anl = solver.StaticAnalysis(mdl, {testcase.name: testcase})
[5]:
static_anl.run()

Retrieving results

Analysis results are stored in dictionaries. The keys are the unique identifiers of the elements that the results correspond to, and the values contain the results.

[6]:
# Show all node displacement results
# DANGER: Don't do this for a large model.
static_anl.results[testcase.name].node_displacements.items()
[6]:
dict_items([(24, {0: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}), (49, {0: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}), (74, {0: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}), (99, {0: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}), (0, {0: [6.077217388360505e-14, -5.00948371060514e-15, -0.0012434581049207574, -2.904146370359182e-06, 4.2750650805991504e-05, 2.4060510336956165e-17]}), (5, {0: [-0.00051300762191398, -0.00014259769541613036, -0.001278295130140584, -1.1883255298923747e-05, 4.275055689217651e-05, -2.2290308166820296e-14]}), (6, {0: [-0.0005130062258943121, -0.00014259779754629686, -0.0012085938246263793, -1.1883167658359804e-05, 4.2750556898954275e-05, -1.1842742586825059e-15]}), (11, {0: [-0.0010260133585415767, -0.00028519569627034804, -0.0012434304041745445, -2.904172890016723e-06, 4.27504808740645e-05, -8.151277311395972e-15]}), (25, {0: [6.077217388360505e-14, 3.6523000106434926e-15, -0.001243458104921053, -2.904146370125954e-06, -4.2750650805523414e-05, 2.4060510336956165e-17]}), (30, {0: [0.0005130076220299836, -0.00014259769540812573, -0.0012782951301414493, -1.1883255298749383e-05, -4.275055689102798e-05, 2.224258561831612e-14]}), (31, {0: [0.0005130062260027164, -0.00014259779753829222, -0.0012085938246261057, -1.1883167658185435e-05, -4.275055689787406e-05, 9.786615421054387e-16]}), (36, {0: [0.0010260133586444402, -0.0002851956962630005, -0.0012434304041748407, -2.9041728898688143e-06, -4.2750480872830646e-05, 8.15708438280715e-15]}), (50, {0: [5.2110390161299826e-14, 3.6523000106434926e-15, -0.0012434581049209949, 2.904146370558073e-06, -4.275065080529906e-05, 2.4060510336956165e-17]}), (55, {0: [0.0005130062260052987, 0.000142597797544178, -0.0012085938246267673, 1.1883167658296364e-05, -4.275055689791873e-05, -1.2354695242904516e-15]}), (56, {0: [0.0005130076220138908, 0.00014259769541401154, -0.001278295130140672, 1.1883255298860317e-05, -4.2750556891352486e-05, -2.2513331234171744e-14]}), (61, {0: [0.0010260133586395914, 0.00028519569626746753, -0.0012434304041747826, 2.904172890015027e-06, -4.27504808729107e-05, -8.263113104198386e-15]}), (75, {0: [5.2110390161299826e-14, -5.00948371060514e-15, -0.0012434581049208273, 2.9041463701166463e-06, 4.275065080626817e-05, 2.4060510336956165e-17]}), (80, {0: [-0.0005130062258979672, 0.00014259779753688796, -0.0012085938246256102, 1.188316765818151e-05, 4.27505568983157e-05, 1.4078959564943217e-15]}), (81, {0: [-0.000513007621917656, 0.0001425976954067215, -0.0012782951301414933, 1.1883255298745455e-05, 4.275055689178558e-05, 2.2581494411108694e-14]}), (86, {0: [-0.001026013358540246, 0.0002851956962615492, -0.0012434304041746148, 2.9041728899429517e-06, 4.2750480873325916e-05, 8.462129392489635e-15]}), (12, {0: [1.2300191987431927e-13, -7.839013342511252e-15, -0.0018248365169559392, -8.438105889548472e-06, 4.746996629767614e-05, 7.265978187337812e-18]}), (17, {0: [-0.0005696405290623798, -0.00017257039965445445, -0.001926078625402912, -1.43809471318599e-05, 4.746981893786163e-05, -1.8304042272245945e-14]}), (18, {0: [-0.0005696358672573478, -0.00017256979129464048, -0.0017235638674250049, -1.438086057700489e-05, 4.746981893343483e-05, 5.086407372632248e-15]}), (23, {0: [-0.001139275642069882, -0.0003451404369894409, -0.0018248055302155272, -8.438030069176435e-06, 4.746970433333261e-05, 5.627987157145529e-15]}), (37, {0: [1.2300191987431927e-13, -5.223261195297185e-15, -0.0018248365169563805, -8.438105889005036e-06, -4.746996629716906e-05, 7.265978187337812e-18]}), (42, {0: [0.0005696405293061836, -0.00017257039965088363, -0.0019260786254024075, -1.4380947131218053e-05, -4.746981893738382e-05, 1.8473519658882566e-14]}), (43, {0: [0.0005696358675054213, -0.0001725697912910696, -0.0017235638674263924, -1.4380860576363044e-05, -4.746981893285971e-05, -4.994252801589773e-15]}), (48, {0: [0.0011392756423157554, -0.000345140436984915, -0.0018248055302159684, -8.438030068621429e-06, -4.746970433261884e-05, -5.601511640361565e-15]}), (62, {0: [1.203861677291562e-13, -5.223261195297185e-15, -0.0018248365169562407, 8.438105889656377e-06, -4.746996629728229e-05, 7.265978187337812e-18]}), (67, {0: [0.0005696358675051815, 0.0001725697912813838, -0.0017235638674259063, 1.4380860576988722e-05, -4.7469818932669144e-05, 5.006683277731274e-15]}), (68, {0: [0.000569640529296933, 0.0001725703996411978, -0.0019260786254026141, 1.4380947131843726e-05, -4.746981893711961e-05, -1.8323519402311844e-14]}), (73, {0: [0.0011392756423088807, 0.00034514043697598986, -0.0018248055302158288, 8.438030069215146e-06, -4.7469704332139476e-05, 5.622390193220338e-15]}), (87, {0: [1.203861677291562e-13, -7.839013342511252e-15, -0.001824836516956146, 8.438105888739723e-06, 4.7469966297534856e-05, 7.265978187337812e-18]}), (92, {0: [-0.0005696358672600375, 0.00017256979127733756, -0.001723563867427307, 1.4380860576307215e-05, 4.746981893333918e-05, -4.919169124983794e-15]}), (93, {0: [-0.0005696405290674585, 0.00017257039963715153, -0.0019260786254010236, 1.4380947131162213e-05, 4.7469818938009354e-05, 1.8368246384319782e-14]}), (98, {0: [-0.0011392756420750348, 0.0003451404369705131, -0.0018248055302157338, 8.438030068812665e-06, 4.7469704332972685e-05, -5.553682779290589e-15]}), (1, {0: [-6.834256888141942e-10, -3.218152428052707e-11, -0.0012783069746868656, -2.904056968959642e-06, 4.2750604369882017e-05, -1.4845580831325778e-12]}), (2, {0: [7.126745797156546e-10, 4.346362519992914e-11, -0.0012086056860355556, -2.904500607982624e-06, 4.275060437517714e-05, 1.4714891063611004e-12]}), (3, {0: [-6.833863068471305e-10, -3.0646074962228576e-11, -0.0012783069722545196, -1.1883059020697251e-05, 4.275060050019092e-05, -1.3720844581552953e-12]}), (4, {0: [7.127139559935296e-10, 4.286834481519454e-11, -0.0012086056823062015, -1.188312479744748e-05, 4.275060050593396e-05, 1.3584432508892388e-12]}), (7, {0: [-0.0010260140710195056, -0.0002851957570246892, -0.0012782832659363965, -2.9045427077913167e-06, 4.275051600752099e-05, 1.4560523533942942e-12]}), (8, {0: [-0.0010260126750590904, -0.00028519563852627696, -0.0012085819632381258, -2.9039901057583804e-06, 4.27505160106333e-05, -1.476267485675963e-12]}), (9, {0: [-0.0010260140710588875, -0.00028519575786977786, -0.0012782832698821423, -1.1883108732185215e-05, 4.275051893531687e-05, 1.3423687283472277e-12]}), (10, {0: [-0.0010260126750984667, -0.00028519563793099657, -0.00120858196696748, -1.1883124792515217e-05, 4.275051893867218e-05, -1.362599634615487e-12]}), (26, {0: [6.835512928963492e-10, -3.217286249844415e-11, -0.0012783069746877306, -2.9040569688900224e-06, -4.275060436891593e-05, 1.4845001298155106e-12]}), (27, {0: [-7.125571306322933e-10, 4.347228698525237e-11, -0.0012086056860352815, -2.9045006077919246e-06, -4.275060437402602e-05, -1.4716985502617383e-12]}), (28, {0: [6.83511910974412e-10, -3.0637413180144385e-11, -0.0012783069722553846, -1.1883059020522886e-05, -4.275060049923068e-05, 1.3720272931208217e-12]}), (29, {0: [-7.125965069552956e-10, 4.2877006600513475e-11, -0.0012086056823059274, -1.1883124797273108e-05, -4.2750600504777e-05, -1.3586524000075307e-12]}), (32, {0: [0.0010260140711266716, -0.00028519575701734174, -0.001278283265937262, -2.904542707512783e-06, -4.275051600628204e-05, -1.4560898177322756e-12]}), (33, {0: [0.0010260126751576873, -0.00028519563851892943, -0.0012085819632378526, -2.9039901054705358e-06, -4.275051600945486e-05, 1.4760657063347023e-12]}), (34, {0: [0.0010260140711660535, -0.00028519575786243033, -0.001278283269883008, -1.1883108732010845e-05, -4.2750518934073165e-05, -1.3424069809527473e-12]}), (35, {0: [0.0010260126751970636, -0.00028519563792364904, -0.0012085819669672066, -1.1883124792340845e-05, -4.275051893749849e-05, 1.362397560479017e-12]}), (51, {0: [-7.125568698573659e-10, -4.3464982383168055e-11, -0.001208605686035943, 2.904500607849437e-06, -4.2750604374358105e-05, 1.471274401806328e-12]}), (52, {0: [6.835331930629057e-10, 3.2180167096405934e-11, -0.001278306974686953, 2.9040569688876817e-06, -4.2750604368936314e-05, -1.4848451346607677e-12]}), (53, {0: [-7.12596245405995e-10, -4.286970199843135e-11, -0.001208605682306589, 1.1883124797384037e-05, -4.275060050511986e-05, 1.358241123806071e-12]}), (54, {0: [6.834938103665945e-10, 3.064471777810864e-11, -0.0012783069722546072, 1.1883059020633813e-05, -4.2750600499240294e-05, -1.3723665852408282e-12]}), (57, {0: [0.0010260126751628035, 0.00028519563852339645, -0.001208581963238514, 2.9039901057008106e-06, -4.275051600964932e-05, -1.476155174430107e-12]}), (58, {0: [0.0010260140711123734, 0.00028519575702180876, -0.0012782832659364847, 2.9045427077048347e-06, -4.275051600651063e-05, 1.4558933391665063e-12]}), (59, {0: [0.001026012675202179, 0.00028519563792811606, -0.001208581966967868, 1.1883124792451778e-05, -4.275051893770077e-05, -1.3624999010492199e-12]}), (60, {0: [0.0010260140711517562, 0.00028519575786689735, -0.0012782832698822306, 1.1883108732121781e-05, -4.275051893429394e-05, 1.3422047899009697e-12]}), (76, {0: [7.126662810838684e-10, -4.3473644169807064e-11, -0.0012086056860347862, 2.9045006079361722e-06, 4.275060437506997e-05, -1.4712185825806505e-12]}), (77, {0: [-6.83434166524783e-10, 3.21715053155588e-11, -0.0012783069746877746, 2.9040569688841627e-06, 4.275060436970601e-05, 1.4847973732766665e-12]}), (78, {0: [7.127056573777677e-10, -4.2878363785074105e-11, -0.001208605682305432, 1.188312479726918e-05, 4.2750600505825535e-05, -1.358176334996858e-12]}), (79, {0: [-6.833947845737445e-10, 3.063605599726163e-11, -0.0012783069722554288, 1.1883059020518954e-05, 4.2750600500016183e-05, 1.3723277407737064e-12]}), (82, {0: [-0.0010260126750579483, 0.0002851956385174781, -0.0012085819632373569, 2.9039901054974536e-06, 4.275051601005908e-05, 1.476444201046715e-12]}), (83, {0: [-0.0010260140710185337, 0.0002851957570158904, -0.0012782832659373059, 2.9045427074008553e-06, 4.275051600692908e-05, -1.4557092623483633e-12]}), (84, {0: [-0.0010260126750973246, 0.00028519563792219773, -0.001208581966966711, 1.1883124792336922e-05, 4.275051893809883e-05, 1.3627799578697454e-12]}), (85, {0: [-0.0010260140710579159, 0.000285195757860979, -0.0012782832698830517, 1.1883108732006922e-05, 4.275051893472409e-05, -1.3420296297875494e-12]}), (100, {0: [-0.0004905637180669185, -3.52853784046267e-05, -0.0016959194600525188, -2.9041463703527093e-06, 4.740606076243546e-05, 2.5309976031420266e-17]}), (101, {0: [-0.0004905637157488606, -3.52853784046267e-05, -0.0016959194615839355, -2.9041463703527093e-06, 0.00012622041899065594, 2.5309976423995318e-17]}), (102, {0: [-0.0005049920626494717, -3.528537840475169e-05, -0.001463872516107672, -2.9041463703559454e-06, 4.533002537765743e-05, 2.4687127512279544e-17]}), (103, {0: [0.0004905637181827741, -3.528537839362512e-05, -0.0016959194600482236, -2.904146370132446e-06, -4.740606076198527e-05, 2.534024507218362e-17]}), (104, {0: [0.0004905637158647162, -3.528537839362512e-05, -0.0016959194615796403, -2.904146370132446e-06, -0.00012622041899058243, 2.5340245464190693e-17]}), (105, {0: [0.000504992062765328, -3.528537839349999e-05, -0.0014638725161056497, -2.9041463701292e-06, -4.533002537719841e-05, 2.4710277110585826e-17]}), (106, {0: [-0.0002452818578454664, -3.5285378402101433e-05, -0.011994581470169042, -2.9041463702976433e-06, 9.843742985501834e-05, 3.322907476172705e-17]}), (107, {0: [5.792780360996834e-14, -3.5285378399127196e-05, -0.016428406716553542, -2.9041463702425777e-06, -3.733282188009184e-17, 3.5873819047637054e-17]}), (108, {0: [0.000245281857961322, -3.528537839615232e-05, -0.011994581470163744, -2.904146370187512e-06, -9.843742985505595e-05, 3.324420928182e-17]}), (118, {0: [0.0005194202053477476, -0.00013578612519010914, -0.0014213851182237828, -1.6422192651192548e-05, -4.2750556891032145e-05, 2.093709707491594e-14]}), (119, {0: [0.0005194202053477476, -0.00013578612449974842, -0.0014213851196470996, -9.42111567960872e-05, -4.2750556891032145e-05, 2.093709666375921e-14]}), (120, {0: [0.000519420205454061, -0.00014008315444652368, -0.0013441694485586508, -1.4387136224864552e-05, -4.2750556891030064e-05, 2.1588648530554075e-14]}), (121, {0: [0.0005194202053292935, 0.00013578612519601156, -0.0014213851182240935, 1.6422192651299298e-05, -4.2750556891344144e-05, -2.1147664188081392e-14]}), (122, {0: [0.0005194202053292935, 0.00013578612450565084, -0.0014213851196474103, 9.421115679610661e-05, -4.2750556891344144e-05, -2.1147663757276557e-14]}), (123, {0: [0.0005194202054367367, 0.0001400831544524261, -0.0013441694485584227, 1.4387136224973364e-05, -4.275055689134831e-05, -2.1829799738872423e-14]}), (124, {0: [0.0005194202041012222, -6.78930622483986e-05, -0.008683833482652448, -7.54673897539469e-05, -4.2750556891110146e-05, 1.060004925044461e-14]}), (125, {0: [0.0005194202036761725, 2.9512192825566895e-15, -0.011851510636026637, -6.331315542944568e-18, -4.275055689118814e-05, 1.4024004248940607e-16]}), (126, {0: [0.000519420204082297, 6.789306225430103e-05, -0.008683833482653237, 7.546738975394226e-05, -4.275055689126614e-05, -1.044233096009922e-14]}), (136, {0: [0.0004905637181713726, 3.5285378405680175e-05, -0.0016959194600459672, 2.9041463705458083e-06, -4.7406060761769856e-05, 2.6466254512563338e-17]}), (137, {0: [0.0004905637158533147, 3.5285378405680175e-05, -0.001695919461577384, 2.9041463705458083e-06, -0.00012622041899055522, 2.6466255253972682e-17]}), (138, {0: [0.0005049920627539333, 3.528537840580955e-05, -0.0014638725161044814, 2.9041463705519408e-06, -4.533002537697858e-05, 2.527844431094082e-17]}), (139, {0: [-0.0004905637180789269, 3.5285378392160634e-05, -0.001695919460055302, 2.9041463701289203e-06, 4.740606076270161e-05, 2.648411009930303e-17]}), (140, {0: [-0.000490563715760869, 3.5285378392160634e-05, -0.0016959194615867187, 2.9041463701289203e-06, 0.00012622041899070524, 2.64841108403779e-17]}), (141, {0: [-0.0005049920626614874, 3.528537839203118e-05, -0.0014638725161091116, 2.9041463701227835e-06, 4.5330025377928716e-05, 2.529210222632924e-17]}), (142, {0: [0.0002452818579497688, 3.5285378402724416e-05, -0.011994581470161761, 2.9041463704415864e-06, -9.843742985508292e-05, 4.1419895194674907e-17]}), (143, {0: [4.622279446207081e-14, 3.5285378398921164e-05, -0.016428406716554742, 2.9041463703373645e-06, -7.868088295764993e-17, 4.6407417772579024e-17]}), (144, {0: [-0.0002452818578573231, 3.528537839511753e-05, -0.01199458147017296, 2.904146370233142e-06, 9.84374298550024e-05, 4.1428822987732365e-17]}), (154, {0: [-0.0005194202052324366, 0.0001357861251886827, -0.0014213851182237904, 1.6422192651189157e-05, 4.275055689179739e-05, 2.121794922038666e-14]}), (155, {0: [-0.0005194202052324366, 0.000135786124498322, -0.001421385119647107, 9.421115679609436e-05, 4.275055689179739e-05, 2.1217948791220247e-14]}), (156, {0: [-0.0005194202053402259, 0.00014008315444510806, -0.0013441694485586758, 1.4387136224860903e-05, 4.275055689179148e-05, 2.1898258491826882e-14]}), (157, {0: [-0.0005194202052314823, -0.0001357861251981184, -0.0014213851182246296, -1.6422192651360647e-05, 4.2750556892165956e-05, -2.097530633187997e-14]}), (158, {0: [-0.0005194202052314823, -0.0001357861245077577, -0.0014213851196479461, -9.421115679612378e-05, 4.2750556892165956e-05, -2.097530591691424e-14]}), (159, {0: [-0.0005194202053380008, -0.0001400831544545437, -0.0013441694485586493, -1.4387136225035743e-05, 4.2750556892171235e-05, -2.1632248601713883e-14]}), (160, {0: [-0.0005194202039787182, 6.789306224680207e-05, -0.00868383348265311, 7.54673897539555e-05, 4.275055689188953e-05, 1.053654578805071e-14]}), (161, {0: [-0.0005194202035653259, -4.7178533550982575e-15, -0.011851510636027868, 1.1339081361248193e-17, 4.275055689198167e-05, -5.61309976829966e-17]}), (162, {0: [-0.0005194202039852504, -6.789306225623779e-05, -0.008683833482654559, -7.546738975394583e-05, 4.275055689207381e-05, -1.0560081566005613e-14]}), (13, {0: [-2.304214797165777e-09, -4.0576834219539146e-10, -0.0019260934029390257, -8.438071992751653e-06, 4.746989308120308e-05, -2.7020848082681105e-12]}), (14, {0: [2.357556055854143e-09, 4.2247892466349584e-10, -0.0017235786347197183, -8.438196524416553e-06, 4.7469893079665155e-05, 2.6935092247115206e-12]}), (15, {0: [-2.3041428707750075e-09, -4.0398116182309034e-10, -0.0019260934016802197, -1.4380761717687997e-05, 4.746988697984188e-05, -2.4957159545654823e-12]}), (16, {0: [2.3576279297428328e-09, 4.2208491338455574e-10, -0.0017235786342489241, -1.4380832208450062e-05, 4.746988697815273e-05, 2.4869099374163905e-12]}), (19, {0: [-0.0011392779994775148, -0.000345140875628163, -0.001926063828221635, -8.438286405748408e-06, 4.746975686227205e-05, 2.683976834097695e-12]}), (20, {0: [-0.0011392733376128531, -0.0003451400050585649, -0.0017235491001661057, -8.438052911464441e-06, 4.746975685815496e-05, -2.6851249287844815e-12]}), (21, {0: [-0.0011392779995494412, -0.00034514087657987533, -0.0019260638309938408, -1.4380821874546096e-05, 4.746976123969609e-05, 2.4760726282009574e-12]}), (22, {0: [-0.001139273337684727, -0.0003451400046645536, -0.0017235491006368999, -1.438083220696067e-05, 4.7469761235230425e-05, -2.478051947430966e-12]}), (38, {0: [2.304457039806405e-09, -4.057657264352594e-10, -0.0019260934029385211, -8.438071992193363e-06, -4.7469893080960844e-05, 2.7021731276116376e-12]}), (39, {0: [-2.357307261643561e-09, 4.2248154040770146e-10, -0.0017235786347211057, -8.438196523711902e-06, -4.7469893079224095e-05, -2.6933229489842373e-12]}), (40, {0: [2.3043851133741294e-09, -4.039785460629579e-10, -0.0019260934016797151, -1.4380761717046154e-05, -4.746988697959824e-05, 2.495810517697711e-12]}), (41, {0: [-2.3573791354907464e-09, 4.220875291287646e-10, -0.0017235786342503117, -1.4380832207808213e-05, -4.746988697771307e-05, -2.4867309015872937e-12]}), (44, {0: [0.0011392779997227499, -0.0003451408756236371, -0.0019260638282211301, -8.438286404757418e-06, -4.746975686178084e-05, -2.6837261820397058e-12]}), (45, {0: [0.0011392733378603355, -0.000345140005054039, -0.0017235491001674932, -8.438052910982803e-06, -4.746975685737571e-05, 2.6851229627863926e-12]}), (46, {0: [0.0011392779997946763, -0.00034514087657534944, -0.001926063830993336, -1.4380821873904253e-05, -4.7469761239205287e-05, -2.4758282199507528e-12]}), (47, {0: [0.0011392733379322092, -0.0003451400046600277, -0.0017235491006382874, -1.4380832206318824e-05, -4.746976123445077e-05, 2.4780572213453958e-12]}), (63, {0: [-2.3573038950063145e-09, -4.2249198693300064e-10, -0.0017235786347206193, 8.43819652441083e-06, -4.746989307907883e-05, 2.6933905801780246e-12]}), (64, {0: [2.304449015055518e-09, 4.0575527991579215e-10, -0.0019260934029387278, 8.438071992949003e-06, -4.7469893080828626e-05, -2.7020714608395646e-12]}), (65, {0: [-2.3573757688755153e-09, -4.220979756540629e-10, -0.0017235786342498253, 1.438083220843389e-05, -4.746988697757054e-05, 2.486794286675947e-12]}), (66, {0: [2.304377088645257e-09, 4.039680995434911e-10, -0.0019260934016799218, 1.4380761717671819e-05, -4.746988697946329e-05, -2.495705133223481e-12]}), (69, {0: [0.0011392733378569212, 0.0003451400050451138, -0.001723549100167007, 8.438052911510564e-06, -4.74697568571729e-05, -2.6851657287649512e-12]}), (70, {0: [0.0011392779997118415, 0.00034514087561471194, -0.001926063828221337, 8.438286405489361e-06, -4.746975686144761e-05, 2.6839245120879165e-12]}), (71, {0: [0.001139273337928795, 0.00034514000465110255, -0.0017235491006378013, 1.43808322069445e-05, -4.7469761234244696e-05, -2.4780957412112202e-12]}), (72, {0: [0.0011392779997837679, 0.0003451408765664243, -0.0019260638309935429, 1.4380821874529916e-05, -4.7469761238875316e-05, 2.476022832273796e-12]}), (88, {0: [2.357554437005566e-09, -4.224946026724324e-10, -0.0017235786347220205, 8.438196523620392e-06, 4.746989307960609e-05, -2.693273908113786e-12]}), (89, {0: [-2.3042179553477614e-09, 4.0575266415094284e-10, -0.0019260934029371372, 8.438071992086972e-06, 4.74698930814412e-05, 2.7021350397956677e-12]}), (90, {0: [2.357626310720852e-09, -4.221005913934865e-10, -0.0017235786342512263, 1.4380832207752381e-05, 4.746988697809531e-05, -2.4866798577205633e-12]}), (91, {0: [-2.304146028783585e-09, 4.039654837786347e-10, -0.0019260934016783313, 1.4380761716990313e-05, 4.746988698007836e-05, 2.495767261271355e-12]}), (94, {0: [-0.00113927333761655, 0.00034514000503963713, -0.0017235491001684076, 8.438052910689997e-06, 4.7469756858111024e-05, 2.6852240838423144e-12]}), (95, {0: [-0.0011392779994845775, 0.0003451408756092352, -0.0019260638282197463, 8.43828640494958e-06, 4.746975686217761e-05, -2.683898652940018e-12]}), (96, {0: [-0.0011392733376884238, 0.0003451400046456258, -0.0017235491006392018, 1.4380832206262989e-05, 4.746976123518901e-05, 2.4781563394505504e-12]}), (97, {0: [-0.0011392779995565041, 0.0003451408765609475, -0.0019260638309919521, 1.4380821873848412e-05, 4.746976123959913e-05, -2.475995522281192e-12]}), (109, {0: [-0.0005447178632859942, -0.00010252298656576458, -0.002323895350514763, -8.438105889533508e-06, 5.200624095616322e-05, 1.0317667301703801e-17]}), (110, {0: [-0.0005447178607120421, -0.00010252298656576458, -0.0023238953520461794, -8.438105889533508e-06, 0.00012824571905591876, 1.0317668214737724e-17]}), (111, {0: [-0.0005607389768398783, -0.00010252298656581249, -0.0020686985864788307, -8.438105889540991e-06, 4.9989773220363705e-05, 8.832634175164776e-18]}), (112, {0: [0.0005447178635258472, -0.00010252298655672071, -0.002323895350510227, -8.438105889020162e-06, -5.200624095567488e-05, 1.0060351410478512e-17]}), (113, {0: [0.0005447178609518951, -0.00010252298655672071, -0.0023238953520416435, -8.438105889020162e-06, -0.00012824571905583847, 1.0060352328302398e-17]}), (114, {0: [0.0005607389770797261, -0.00010252298655667399, -0.0020686985864767603, -8.4381058890126e-06, -4.9989773219865955e-05, 8.63586111948911e-18]}), (115, {0: [-0.00027235893029605785, -0.0001025229865640185, -0.012751670239791643, -8.438105889405173e-06, 9.945007988764681e-05, 2.871527193697564e-17]}), (116, {0: [1.1992649424614607e-13, -0.00010252298656123171, -0.017228533112562713, -8.438105889276835e-06, -4.009378294580052e-17, 3.4804920531168836e-17]}), (117, {0: [0.0002723589305359108, -0.00010252298655845039, -0.012751670239785963, -8.4381058891485e-06, -9.945007988768688e-05, 2.8586613994824516e-17]}), (127, {0: [0.0005767610019676128, -0.00016432709285864322, -0.002093820422216781, -1.8854862565131784e-05, -4.7469818937377475e-05, 1.7364395032879583e-14]}), (128, {0: [0.0005767610019676128, -0.00016432709202317516, -0.002093820423640098, -9.523850310898031e-05, -4.7469818937377475e-05, 1.7364394684613737e-14]}), (129, {0: [0.000576761002055815, -0.00016952731728960463, -0.002004360125583791, -1.685231709806858e-05, -4.7469818937380646e-05, 1.7917115797295642e-14]}), (130, {0: [0.0005767610019596383, 0.00016432709284905123, -0.0020938204222231203, 1.8854862565732893e-05, -4.746981893713861e-05, -1.7245299531669824e-14]}), (131, {0: [0.0005767610019596383, 0.00016432709201358317, -0.002093820423646437, 9.523850310906565e-05, -4.746981893713861e-05, -1.7245299187522735e-14]}), (132, {0: [0.0005767610020472213, 0.00016952731728001264, -0.0020043601255870947, 1.685231709868179e-05, -4.746981893712911e-05, -1.7787036632139243e-14]}), (133, {0: [0.0005767610009392905, -8.216354601398558e-05, -0.009417139055686282, -7.598106291043552e-05, -4.746981893731776e-05, 8.673370110793136e-15]}), (134, {0: [0.0005767610005965426, -4.795988122262616e-15, -0.012605106298743809, -5.1426560171424955e-17, -4.746981893725804e-05, 8.079607520952537e-18]}), (135, {0: [0.0005767610009373362, 8.216354600439359e-05, -0.009417139055693169, 7.598106291037972e-05, -4.746981893719833e-05, -8.631476825260534e-15]}), (145, {0: [0.0005447178635246097, 0.00010252298655400423, -0.0023238953505112, 8.438105889630973e-06, -5.200624095578409e-05, 1.2183157257972698e-17]}), (146, {0: [0.0005447178609506576, 0.00010252298655400423, -0.0023238953520426163, 8.438105889630973e-06, -0.00012824571905585287, 1.2183158800132659e-17]}), (147, {0: [0.0005607389770784873, 0.00010252298655405902, -0.0020686985864771814, 8.438105889643675e-06, -4.998977321997726e-05, 9.734191713074858e-18]}), (148, {0: [-0.0005447178632869064, 0.00010252298654044667, -0.0023238953505135807, 8.438105888765283e-06, 5.2006240956026795e-05, 1.232131179683417e-17]}), (149, {0: [-0.0005447178607129543, 0.00010252298654044667, -0.002323895352044997, 8.438105888765283e-06, 0.0001282457190558921, 1.23213133364256e-17]}), (150, {0: [-0.0005607389768407838, 0.00010252298654039123, -0.002068698586478337, 8.438105888752503e-06, 4.9989773220224785e-05, 9.83983381380505e-18]}), (151, {0: [0.0002723589305347546, 0.00010252298655149972, -0.012751670239786865, 8.438105889414551e-06, -9.945007988767412e-05, 4.3293478544708735e-17]}), (152, {0: [1.1885164049719058e-13, 0.00010252298654723132, -0.01722853311256209, 8.438105889198129e-06, -2.0316888553572324e-17, 5.368661088217458e-17]}), (153, {0: [-0.0002723589302970513, 0.00010252298654295999, -0.012751670239789754, 8.438105888981705e-06, 9.945007988765345e-05, 4.3362555812751077e-17]}), (163, {0: [-0.0005767610017299691, 0.00016432709284491733, -0.0020938204222148496, 1.8854862565078082e-05, 4.7469818938003385e-05, 1.7270774226846228e-14]}), (164, {0: [-0.0005767610017299691, 0.00016432709200944927, -0.0020938204236381664, 9.523850310897138e-05, 4.7469818938003385e-05, 1.727077388094073e-14]}), (165, {0: [-0.0005767610018176921, 0.00016952731727587142, -0.0020043601255821304, 1.6852317098013826e-05, 4.746981893800637e-05, 1.781871510176267e-14]}), (166, {0: [-0.0005767610017255022, -0.00016432709286232466, -0.002093820422223575, -1.885486256574798e-05, 4.7469818937858454e-05, -1.7209337949853724e-14]}), (167, {0: [-0.0005767610017255022, -0.0001643270920268566, -0.0020938204236468916, -9.523850310905812e-05, 4.7469818937858454e-05, -1.7209337605938768e-14]}), (168, {0: [-0.0005767610018129118, -0.00016952731729327888, -0.002004360125587472, -1.6852317098697412e-05, 4.746981893786004e-05, -1.77550125710308e-14]}), (169, {0: [-0.0005767610007068877, 8.216354600037281e-05, -0.009417139055684214, 7.598106291043998e-05, 4.746981893796715e-05, 8.63209054125888e-15]}), (170, {0: [-0.0005767610003657713, -8.703662925577405e-15, -0.01260510629874242, 6.30960041199386e-17, 4.746981893793092e-05, 5.844180194986052e-18]}), (171, {0: [-0.0005767610007056369, -8.216354601778014e-05, -0.009417139055692782, -7.598106291036702e-05, 4.7469818937894686e-05, -8.607965202205372e-15]}), (172, {0: [5.644128202157356e-14, -6.785918497944255e-16, 0.0, 0.0, 0.0, 2.4060510336956165e-17]}), (173, {0: [1.2169404380173774e-13, -6.531137268840807e-15, 0.0, 0.0, 0.0, 7.265978187337812e-18]})])
[7]:
# Displacement of the parent node of the top story,
# in the Y direction.
analysis_step = 0
direction = 1
node_id = testcase.parent_nodes[2].uid
static_anl.results[testcase.name].node_displacements[
    node_id][analysis_step][direction]
[7]:
-6.531137268840807e-15

Note: Multiple load cases and analysis objects can be defined using the same model. The results will be stored independently in the various analysis objects.

Visualizing results

The following visualization methods work for all analysis methods. However, some require specifying the analysis step to visualize. Static analyses only have a single step, so we specify 0.

[8]:
from osmg.graphics.postprocessing_3d import show_deformed_shape
from osmg.graphics.postprocessing_3d import show_basic_forces
[9]:
help(show_deformed_shape)
Help on function show_deformed_shape in module osmg.graphics.postprocessing_3d:

show_deformed_shape(analysis, case_name, step, scaling, extrude, camera=None, subset_model=None, animation=False, init_step=0, step_skip=0)
    Visualize the model in its deformed state
    Arguments:
      analysis: an analysis object
      case_name: the name of the load_case to be visualized
      step: the analysis step to be visualized
      scaling: scaling factor for the deformations. If 0.00 is
        provided, the scaling factor is calculated automatically.
      extrude: wether to extrude frame elements
      camera: custom positioning of the camera
      subset_model: subset model used to only show certain
        components
      animation: show all frames up to the one identified with
        `step`
      init_step: starting step, in case of animation
      step_skip: how many frames to skip to reduce the number of
        frames in case an animation.

[10]:
show_deformed_shape(static_anl, testcase.name, 0, 0.00, True)
[10]:
{'scaling': 2228.8606783359555}
[11]:
help(show_basic_forces)
Help on function show_basic_forces in module osmg.graphics.postprocessing_3d:

show_basic_forces(analysis, case_name, step, scaling_global, scaling_n, scaling_q, scaling_m, scaling_t, num_points, force_conversion=1.0, moment_conversion=1.0, global_axes=False, camera=None, subset_model=None)
    Visualize the model and plot the frame element basic forces
    Arguments:
      analysis: an analysis object
      case_name: the name of the load_case to be visualized
      step: the analysis step to be visualized
      scaling_global: I don't even remember what this
        does. It's kind of a mess right now.
      scaling_n:
      scaling_q:
      scaling_m:
      scaling_t:
      num_points: number of points to include in the basic force
        curves
      force_conversion: Conversion factor to be applied at the
        hover box data for forces (for unit conversions)
      moment_conversion: Conversion factor to be applied at the
        hover box data for moments (for unit conversions)
      global_axes: whether to show global axes
      camera: custom positioning of the camera
      subset_model: use this model instead of the one
        contained in the analysis object.
        It needs to be a subset of the original model. This can be
          used to only show the results for some part of a large
          model.

[12]:
show_basic_forces(static_anl, testcase.name, 0, 1.00, 1.00, 1.00, 1.00, 1.00, 10, 1.00, 1.00, False)
[12]:
{'scaling_n': 0.0023066665064812855,
 'scaling_q': 0.011840888066589604,
 'scaling_m': 0.00018739274636028717,
 'scaling_t': 1.0}

Time-history analysis

[18]:
nlth_anl = solver.NLTHAnalysis(mdl, {testcase.name: testcase})
[19]:
help(nlth_anl.run)
Help on method run in module osmg.solver:

run(analysis_time_increment: 'float', filename_x: 'str', filename_y: 'str', filename_z: 'str', file_time_incr: 'float', finish_time: 'float' = 0.0, skip_steps: 'int' = 1, damping: 'dict[str, Optional[Union[str, float, int, list[float]]]]' = {'type': None}, print_progress: 'bool' = True) -> 'dict[str, Union[int, str, float]]' method of osmg.solver.NLTHAnalysis instance
    Run the nonlinear time-history analysis
    Arguments:
        filename_x, y, z: Paths where the fixed-step ground acceleration
                          records are stored (single-column).
        file_time_incr:   The corresponding time increment
        finish_time: Specify a target time (s) to stop the analysis
                     the default value of 0.00 means that it will
                     run for the entire duration of the files.
        damping: Can be any of:
                 {'type': None},
                 {'type': 'rayleigh', 'ratio': r, 'periods': [t1, t2]},
                 {'type': 'stiffness', 'ratio': r, 'period': t1}
                 {'type': 'modal', 'num_modes': n, 'ratio': r}
                 {'type': 'modal+stiffness', 'num_modes': n,
                          'ratio_modal': r, 'period': t1,
                          'ratio_stiffness': r}
        print_progress: Controls whether the current time is printed out

[20]:
nlth_anl.run(
    0.01,
    'groundmotions/1xa.txt',
    'groundmotions/1ya.txt',
    None,
    0.005,
    damping={'type': 'rayleigh', 'ratio': 0.05, 'periods': [1.00, 0.30]},
    print_progress=True
)
100%|█████████▉| 30.38000000000195/30.400000000000002 [01:33<00:00,  1.85s/it]/home/runner/.local/lib/python3.10/site-packages/tqdm/std.py:533: TqdmWarning:

clamping frac to range [0, 1]

100%|██████████| 30.400000000001953/30.400000000000002 [01:33<00:00,  3.08s/it]
[20]:
{'successful steps': 3040, 'analysis_finished_successfully': True}
[21]:
parent_node_lvl2 = testcase.parent_nodes[2]
[22]:
nlth_anl.plot_node_displacement_history(testcase.name, parent_node_lvl2, 0, plotly=True)